home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13759 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  49 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!zodiac!szh
  3. From: szh@zcon.com (Syed Zaeem Hosain)
  4. Subject: Re: accessing structures via pointers
  5. Message-ID: <1996Apr10.045928.18797@zcon.com>
  6. Sender: szh@zcon.com (Syed Zaeem Hosain)
  7. Nntp-Posting-Host: zodiac
  8. Reply-To: szh@zcon.com
  9. Organization: Z Consulting Group
  10. References: <4kcn32$564@uhura.phoenix.net>
  11. Date: Wed, 10 Apr 1996 04:59:28 GMT
  12.  
  13. In article <4kcn32$564@uhura.phoenix.net>, brucew@phoenix.net (Bruce Wedding) writes:
  14. >In comp.lang.c
  15. >csyamc@scs.leeds.ac.uk (A M Casey) wrote:
  16. >
  17. >> struct group {
  18. >>                 char    *gr_name;   /* the name of the group */
  19. >>                 char    *gr_passwd; /* the encrypted group password */
  20. >>                 gid_t   gr_gid;     /* the numerical group ID */
  21. >>                 char    **gr_mem;   /* vector of pointers to member names */
  22. >>          };
  23. >
  24. >I assume the function is allocating memory for these strings?
  25. >
  26. >>printf("the group name is %s\n",tempgroup.gr_name);
  27. >
  28. >Try it like this:
  29. >
  30. >printf("the group name is %s\n",tempgroup->gr_name);
  31. >
  32. >which is an easier way than doing this:
  33. >
  34. >printf("the group name is %s\n",*(tempgroup).gr_name);
  35.                                  ^^^^^^^^^^^^^^^^^^^^
  36.  
  37. Uhhh ... wouldn't this be (*tempgroup).gr_name rather than what you
  38. show? Looks like a typo to me. Of course, the first way is much
  39. more the way to go since it avoids these problems!    :-)
  40.  
  41.                                 Z
  42.  
  43.  
  44. -- 
  45. -------------------------------------------------------------------------
  46. | Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
  47. | Z Consulting Group        San Jose, CA 95161             szh@zcon.com |
  48. -------------------------------------------------------------------------
  49.